package command.gew;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import model.Emocao;
import model.Respondente;

import command.ICommand;

import dao.RespondenteDAO;

public class ListarRespondentesParaGewCommand implements ICommand{

	@Override
	public String execute(HttpServletRequest request) throws ServletException,IOException {
		RespondenteDAO dao = new RespondenteDAO();
		ArrayList<Emocao> emocoes =(ArrayList<Emocao>)request.getAttribute("emocoes");
		ArrayList<String> respondentesAdicionados =(ArrayList<String>)request.getAttribute("respondentesAdicionados");
		try {
			ArrayList<Respondente> respondentes = dao.listar();
			request.setAttribute("respondentes", respondentes);
			request.setAttribute("emocoes", emocoes);
			request.setAttribute("resp", respondentesAdicionados);
			return "/paginas/questionario/configurar_respondente_questionario.jsp";
		} catch (SQLException e) {
			e.printStackTrace();
			return "/paginas/tela_principal.jsp";
		}
	}

}
